Problem Challenge 3

We'll cover the following

Rotation Count (medium) #

Given an array of numbers which is sorted in ascending order and is rotated ‘k’ times around a pivot, find ‘k’.

You can assume that the array does not have any duplicates.

Example 1:

Input: [10, 15, 1, 3, 8]
Output: 2
Explanation: The array has been rotated 2 times.
Created with Fabric.js 1.6.0-rc.1 1 3 8 10 15 Original array: Array after 2 rotations: 10 15 1 3 8

Example 2:

Input: [4, 5, 7, 9, 10, -1, 2]
Output: 5
Explanation: The array has been rotated 5 times.
Created with Fabric.js 1.6.0-rc.1 Original array: -1 2 4 5 7 9 10 4 5 7 9 10 -1 2 Array after 5 rotations:

Example 3:

Input: [1, 3, 8, 10]
Output: 0
Explanation: The array has been not been rotated.

Try it yourself #

Try solving this question here:

Output

0.477s

-1 -1 -1

Mark as Completed
←    Back
Solution Review: Problem Challenge 2
Next    →
Solution Review: Problem Challenge 3